package de.bht.cge.flightsim.game;

import java.awt.Color;
import java.io.File;

import de.bht.jvr.collada14.loader.ColladaLoader;
import de.bht.jvr.core.Finder;
import de.bht.jvr.core.SceneNode;
import de.bht.jvr.core.ShaderMaterial;
import de.bht.jvr.core.Transform;
import de.bht.jvr.core.uniforms.UniformColor;

public class Tree extends Base
{
    private String path;
    
    public Tree(float scale,String path)
    {
        super(scale,"Tree");
        this.setPath(path);
        
        try
        {
            this.Build();
        }
        catch(Exception e)
        {
            e.printStackTrace();
        }
    }
    
    @Override
    public void Build() throws Exception
    {
        super.Build();
        
        SceneNode tree = ColladaLoader.load(new File("meshes/"+this.getPath()));
        tree.setTransform(Transform.scale(this.getScale()));
        
        ShaderMaterial mat = (ShaderMaterial)Finder.findMaterial(tree, null);
        mat.setMaterialClass("Translucent");
        mat.setUniform("AMBIENT", "jvr_Material_Ambient", new UniformColor(new Color(0.5f, 0.5f, 0.5f, 1.0f)));
        this.addChildNode(tree);
        
    }

    private String getPath()
    {
        return path;
    }

    private void setPath(String path)
    {
        this.path=path;
    }
    
}
